<template>
  <basic-container>
    <el-tabs type="border-card" class="informationLabel" v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="最小包标签生成及打印" name="min">
        <el-tabs type="border-card" class="informationLabel">
          <el-tab-pane label="标签生成及打印">
            <el-row :gutter="20">
              <el-col :span="11">
                <avue-form
                  id="rawMaterialOtherForm"
                  class="newFormStyle"
                  key="2"
                  ref="rawMaterialOtherForm"
                  v-model="rawMaterialOtherForm"
                  :option="rawMaterialOtherOption"
                  @submit="rawMaterialOtherLabelGenerate"
                >
                  <template slot-scope="{}" slot="mpqLabel">
                    <el-tooltip class="item" effect="dark" content="MPQ（Minimum Package Quantity）指物料最小包装数量" placement="top-start">
                      <i class="el-icon-info"></i>
                    </el-tooltip>
                    <span>&nbsp;MPQ:</span>
                  </template>
                </avue-form>
              </el-col>
              <el-col :span="12">
                <div class="sequenceInfo">
                  <table border="1">
                    <tr>
                      <th colspan="4">序列号规则</th>
                    </tr>
                    <tr>
                      <th>规则名称</th>
                      <th>
                        <el-tooltip class="item" effect="dark" placement="top-start">
                          <i class="el-icon-info" style="color: #606266"></i>
                          <div slot="content">
                            [P]：前缀字符,[YY]：两位年份, [YYYY]：四位年份, [M]：月,<br />[W]：周, [D]：日, [S]：流水号, [N]：自定义字符。<br />[B]：后缀字符
                            <br />如：[YY][M][S][B] <br />若无流水号则没有[S],例如：[YY][M][B]
                          </div>
                          <!-- <el-button style="padding: 0; font-size: 18px" type="info" icon="el-icon-info" circle></el-button> -->
                        </el-tooltip>
                        序列号规则
                        <el-button
                          v-if="sequenceRuleInfo && sequenceRuleInfo.sequenceNoFormat"
                          style="padding: 5px"
                          type="primary"
                          icon="el-icon-edit"
                          circle
                          @click="openTimeConfigModel"
                        ></el-button>
                      </th>
                      <th>序列号规则位数</th>
                      <th>当前流水号</th>
                    </tr>
                    <tr style="height: 40px">
                      <td>{{ sequenceRuleInfo.name }}</td>
                      <td>
                        <div>{{ sequenceRuleInfo.sequenceNoFormat }}</div>
                        <div>{{ sequenceRuleInfo.sequenceNoFormatZh }}</div>
                      </td>
                      <td>
                        <div>{{ sequenceRuleInfo.snLength }}</div>
                      </td>
                      <td>{{ sequenceRuleInfo.sequenceNo }}</td>
                    </tr>
                  </table>
                  <table class="generateSerialNoInfo" border="1">
                    <tr>
                      <th colspan="4">序列号预览</th>
                    </tr>
                    <tr>
                      <div style="font-size: 15px; margin: 15px">序列号数量:{{ sequenceRuleInfo.quantity }}</div>
                      <div style="font-size: 15px; margin: 15px">起始序列号:{{ sequenceRuleInfo.sequenceNumberFrom }}</div>
                      <div style="font-size: 15px; margin: 15px">结尾序列号:{{ sequenceRuleInfo.sequenceNumberTo }}</div>
                    </tr>
                  </table>
                  <el-row>
                    <el-col :span="15">
                      <barcode-printer-template ref="printInfo" templateType="MATERIAL" @getPrintInfo="getPrintInfo"></barcode-printer-template>
                    </el-col>
                    <el-col :span="15" class="btn-group">
                      <el-button type="primary" size="small" @click="handleCreatLabel">生成标签 </el-button>
                      <el-button type="primary" size="small" @click="batchPrinting" :loading="btnLoading"> 打印标签 </el-button>
                    </el-col>
                  </el-row>
                </div>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
      </el-tab-pane>
      <el-tab-pane label="内外包标签生成及打印" name="out">
        <in-out-generation v-if="activeName === 'out'"></in-out-generation>
      </el-tab-pane>
    </el-tabs>

    <common-modal-template ref="commonModalTemplate" :option="tableOption" @getSelectedRows="getSelectedRows" :key="timer" @newKey="newKey"></common-modal-template>
    <recive-dialog ref="reciveDialog" :option="tableOption" @getSelectedRows="getSelectedRows"></recive-dialog>
    <el-tabs type="border-card" class="informationLabel mt8" v-if="activeName === 'min'">
      <el-tab-pane label="包装条码生成记录">
        <avue-crud
          :defaults.sync="recordDefaults"
          class="serialNoGenerationRecord"
          ref="serialNoGenerationRecord"
          :table-loading="loading"
          :option="serialNoGenerationRecordOption"
          :data="serialnoData"
          :page.sync="page"
          @current-change="currentChange"
          @size-change="sizeChange"
          :row-style="rowStyle"
          @row-click="serialnoRowClick"
        >
          <template slot-scope="{ row }" slot="menu">
            <div class="menu-option">
              <el-button
                icon="el-icon-printer"
                :disabled="row.isPrinted !== 1 || ['REVORK', 'SCRAP'].includes(row.generationType)"
                size="small"
                type="text"
                @click="rowPrint(row)"
              >
                重打
              </el-button>
            </div>
          </template>
        </avue-crud>
      </el-tab-pane>
    </el-tabs>

    <!-- 操作日志 -->
    <operation-log ref="operationLog" v-if="activeName === 'min'"></operation-log>
    <!--重打弹窗-->
    <el-dialog append-to-body title="重打" v-if="printInfoModel" :visible.sync="printInfoModel" width="35%">
      <div style="display: flex; justify-content: center; margin-bottom: 10px">
        <span style="color: red">注：仅需修改流水号即可，重打的起始流水号和结束流水号需在原流水号范围内</span>
      </div>
      <avue-form ref="printForm" v-model="repeatPrintInfo" :option="printInfoOption"></avue-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" @click="printSubmit"><i class="el-icon-printer"></i><span>重打</span></el-button>
        <el-button size="small" @click="printInfoModel = false"><i class="el-icon-circle-close"></i><span>取 消</span></el-button>
      </span>
    </el-dialog>
    <!--请确认标签生成信息-->
    <el-dialog append-to-body title="请确认标签生成信息" :visible.sync="confirmVisible" width="30%">
      <avue-form ref="timeConfigForm" v-model="confirmModel" :option="confirmModelOption">
        <template slot="number">
          <el-input disabled class="input-text" v-model="confirmModel.number"></el-input>
        </template>
      </avue-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="$refs.rawMaterialOtherForm.submit()" v-preventReClick
          ><i class="el-icon-circle-plus-outline"></i><span>保 存</span></el-button
        >
        <el-button size="small" @click="confirmVisible = false"><i class="el-icon-circle-close"></i><span>取 消</span></el-button>
      </span>
    </el-dialog>
    <el-dialog append-to-body title="序列号规则时间修改" :visible.sync="timeConfigModel" width="30%">
      <avue-form ref="timeConfigForm" v-model="timeConfig" :option="timeConfigOption"></avue-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="onSaveTimeConfig"><i class="el-icon-circle-plus-outline"></i><span>保 存</span></el-button>
        <el-button size="small" @click="timeConfigModel = false"><i class="el-icon-circle-close"></i><span>取 消</span></el-button>
      </span>
    </el-dialog>
    <!--其他信息弹窗-->
    <el-dialog append-to-body title="其他信息" :visible.sync="otherInfoDialog" width="30%">
      <div class="form-contant" v-if="fieldList.length">
        <avue-form ref="otherInfo" v-model="otherInfo" :option="otherInfoOption" @submit="otherInfoSubmit"></avue-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="saveOtherInfo"><i class="el-icon-circle-plus-outline"></i><span>保 存</span></el-button>
        <el-button size="small" @click="otherInfoDialog = false"><i class="el-icon-circle-close"></i><span>取 消</span></el-button>
      </span>
    </el-dialog>
  </basic-container>
</template>

<script>
import { getRawMaterialOtherOption } from './barcodeGeneration';
import { receivingPreview } from '@/api/product/product-label-create-print';
import { getYearWeek, showFailLog, showSuccessLog } from '@/util/helpers';
import { getIsAllowMultiplePrint, getSourceList, printSequence, printTest, sequenceCreate } from '@/api/warehouse/warehouse-label-create-print';
import CommonModalTemplate from '@/components/common-modal-template/common-modal-template.vue';
import barcodePrinterTemplate from '@/views/product/components/barcode-printer-template';
import OperationLog from '@/components/operation-log/operation-log';
import { getDefault, getDetail as getSequencedefinitionDetail } from '@/api/admin/sequencedefinition';
import { getSeqNoRules } from '@/util/global';
import { getPrintHistory, packPrint } from '@/api/admin/barcode-record';
import { getDetail } from '@/api/labelManagement/tagDataSource';
import reciveDialog from '@/views/product/components/reciveDialog';
import InOutGeneration from '@/views/product/inOutGeneration.vue';

export default {
  name: 'barcodeGeneration',
  components: {
    InOutGeneration,
    CommonModalTemplate,
    reciveDialog,
    barcodePrinterTemplate,
    OperationLog
  },
  data() {
    return {
      btnLoading: false,
      fieldList: [],
      otherInfoDialog: false,
      otherInfo: {},
      activeName: 'min',
      otherInfoOption: {
        submitBtn: false,
        emptyBtn: false,
        column: []
      },
      sourceId: '',
      page: {
        pageSize: 20,
        currentPage: 1,
        total: 0
      },
      confirmVisible: false,
      confirmModel: {},
      confirmModelOption: {
        labelWidth: 150,
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: '供应商名称',
            prop: 'vendorName',
            span: 24,
            disabled: true
          },
          {
            label: '物料编码',
            prop: 'partNo',
            span: 24,
            disabled: true
          },
          {
            label: '物料名称',
            prop: 'partName',
            span: 24,
            disabled: true
          },
          {
            label: '物料规格',
            prop: 'partModel',
            span: 24,
            disabled: true
          },
          {
            label: 'MPQ',
            prop: 'mpq',
            span: 24,
            disabled: true
          },
          {
            label: '本次生成数量',
            prop: 'generationQuantity',
            span: 24,
            disabled: true
          },
          {
            label: '序列号/包装条码数量',
            prop: 'number',
            span: 24,
            disabled: true
          }
        ]
      },
      rawMaterialOtherForm: {}, //序列号生成信息,
      tableOption: {},
      timer: new Date().getTime(),
      loading: false,
      selectionInfo: {},
      recordDefaults: {},
      serialNoGenerationRecordOption: {
        //工单产品序列号内容配置
        height: 300,
        calcHeight: 30,
        border: true,
        index: true,
        indexLabel: '序号',
        viewBtn: false,
        selection: false,
        dialogClickModal: false,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        tip: false,
        refreshBtn: false, //刷新按钮是否显示
        columnBtn: false, //控制表格列是否显示按钮是否显示
        menu: true,
        highlightCurrentRow: true,
        column: [
          {
            label: '起始包装条码',
            prop: 'sequenceNumberFrom'
          },
          {
            label: '结尾包装条码',
            prop: 'sequenceNumberTo'
          },
          {
            label: '包装条码数量',
            prop: 'quantity'
          },
          {
            label: '最小包装数量（MPQ）',
            prop: 'packingSpecQty'
          },
          {
            label: '状态',
            prop: 'isPrinted',
            html: true,
            formatter: (val) => {
              switch (val.isPrinted) {
                case 0:
                  return `<span class="text-yellow">未打印</span>`;
                case 1:
                  return `<span class="text-green">已打印</span>`;
                case 2:
                  return `<span class="text-red">部分打印</span>`;
                default:
                  return `<span class="text-red">报废</span>`;
                  break;
              }
            }
          },
          {
            label: '生成时间',
            prop: 'createTime'
          },
          {
            label: '生成类型',
            prop: 'generationType',
            html: true,
            formatter: (val) => {
              switch (val.generationType) {
                case 'GENERATE':
                  return '正常';
                case 'SCRAP':
                  return '报废';
                case 'APPEND':
                  return '增补';
                case 'REPLACE':
                  return '置换';
                case 'REVORK':
                  return '撤销';
                default:
                  break;
              }
            }
          }
        ]
      },
      serialnoData: [],
      printInfo: {}, //打印机打印模版信息
      sequenceRuleInfo: {}, //产品序列号规则信息
      printInfoModel: false,
      repeatPrintInfo: {},
      printInfoOption: {
        labelWidth: 150,
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: '起始流水号',
            prop: 'startSequenceNumber',
            span: 20
          },
          {
            label: '结束流水号',
            prop: 'endSequenceNumber',
            span: 20
          },
          {
            label: '标签模版',
            prop: 'name',
            span: 20,
            type: 'search',
            placeholder: '请选择 标签模板',
            disabled: true,
            rules: [
              {
                required: true,
                message: '请选择标签模板',
                trigger: 'blur'
              }
            ],
            appendClick: () => {
              this.openLabelTemplateModal();
            }
          },
          {
            label: '打印机',
            prop: 'equipmentName',
            span: 20,
            type: 'search',
            placeholder: '请选择 打印机',
            disabled: true,
            rules: [
              {
                required: true,
                message: '请选择打印机',
                trigger: 'blur'
              }
            ],
            appendClick: () => {
              this.openPrintersModal();
            }
          }
        ]
      },
      rawMaterialOtherOption: getRawMaterialOtherOption(this), //序列号生成信息配置内容
      timeConfigModel: false, //序列号规则时间修改模态框是否显示
      timeConfig: {}, //序列号规则时间配置
      timeConfigOption: {
        //序列号规则时间修改内容配置
        labelWidth: 150,
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: '年代码',
            prop: 'year',
            type: 'year',
            format: 'yyyy',
            valueFormat: 'yyyy',
            span: 20,
            display: false
          },
          {
            label: '月代码',
            prop: 'month',
            type: 'month',
            format: 'MM',
            valueFormat: 'MM',
            span: 20,
            display: false
          },
          {
            label: '周代码',
            prop: 'week',
            span: 20,
            display: false
          },
          {
            label: '日代码',
            prop: 'day',
            type: 'date',
            format: 'dd',
            valueFormat: 'dd',
            span: 20,
            display: false,
            change(val) {
              console.log(val, Date.parse(val), Object.prototype.toString.call(Date.parse(val)));
            }
          }
        ]
      }
    };
  },
  created() {
    this.getPageConfig();
  },
  mounted() {},
  methods: {
    async getPageConfig() {
      try {
        const res = await getIsAllowMultiplePrint();
        const [config] = res.data.data.records;
        this.configValue = config.paramValue;
      } catch (e) {
        console.log(e);
      }
    },
    rawMaterialOtherLabelGenerate(row, done) {
      this.rawMaterialOtherForm['timeConfig'] = this.timeConfig;
      sequenceCreate(this.rawMaterialOtherForm).then(
        (res) => {
          this.getSequenceRecordById(this.rawMaterialOtherForm.receivingIds);
          this.$message({
            type: 'success',
            message: res.data.msg
          });
          this.confirmVisible = false;
          const obj = {
            generationQuantity: '',
            remark: '',
            quantityPrinted: Number(this.rawMaterialOtherForm.quantityPrinted) + Number(this.rawMaterialOtherForm.generationQuantity)
          };
          Object.assign(this.rawMaterialOtherForm, obj);
          showSuccessLog(res.data.msg);
          done();
        },
        (error) => {
          showFailLog(error.data.msg);
          done();
        }
      );
    },
    //打印测试
    handlePrintTest() {
      if (!this.printInfo.printersId) {
        this.$message({
          type: 'warning',
          message: '请选择打印机！'
        });
        return;
      }
      if (!this.printInfo.labelTemplateId) {
        this.$message({
          type: 'warning',
          message: '请选择标签模版！'
        });
        return;
      }
      let params = {
        printId: this.printInfo.printersId,
        labelTemplateId: this.printInfo.labelTemplateId
      };
      printTest(params).then(
        (res) => {
          this.$message({
            type: 'success',
            message: res.data.msg
          });
          showSuccessLog(res.data.msg);
          // this.getSequenceRecordById(this.getRecordReceivingId);
        },
        (error) => {
          showFailLog(error.data.msg);
        }
      );
    },

    /**
     * 标签打印
     */
    batchPrinting() {
      try {
        if (!Object.keys(this.selectionInfo).length) {
          this.$message({
            type: 'warning',
            message: '请选择一条生产记录'
          });
          return;
        }
        if (!this.printInfo.printersId) {
          this.$message({
            type: 'warning',
            message: '请选择打印机！'
          });
          return;
        }
        if (!this.printInfo.labelTemplateId) {
          this.$message({
            type: 'warning',
            message: '请选择标签模版！'
          });
          return;
        }

        if (!this.fieldList.length) {
          this.handlePrintSequence();
        } else {
          // 当标签模版绑定了数据源且设置了数据 打开其他信息弹窗
          this.otherInfoDialog = true;
        }
      } catch (e) {
        console.warn(e);
      }
    },
    async otherInfoSubmit(row, done) {
      try {
        // 去除row中包含 $的key
        const otherInfo = this.filterChart(row);
        await this.handlePrintSequence(otherInfo);
        this.otherInfoDialog = false;
      } catch (e) {
        console.log(e);
      } finally {
      }
      done();
    },
    filterChart(row = {}) {
      const filteredRow = Object.keys(row).reduce((acc, key) => {
        if (!key.includes('$')) {
          acc[key] = row[key];
        }
        return acc;
      }, {});
      return filteredRow;
    },
    saveOtherInfo() {
      this.$refs.otherInfo.submit();
    },
    handlePrintSequence(otherInfo = {}) {
      let params = {
        equipmentId: this.printInfo.printersId,
        labelTemplateId: this.printInfo.labelTemplateId,
        // receivingId: this.rawMaterialOtherForm.receivingId,
        sequenceGenerationId: this._get(this.selectionInfo, 'id', '')
      };
      if (Object.keys(otherInfo).length) {
        params.printInput = JSON.stringify(otherInfo);
      }
      printSequence(params).then(
        (res) => {
          this.$message({
            type: 'success',
            message: res.data.msg
          });
          showSuccessLog(res.data.msg);
          this.getSequenceRecordById(this.rawMaterialOtherForm.receivingIds);
        },
        (error) => {
          showFailLog(error.data.msg);
        }
      );
    },
    // 重打
    async rowPrint(row) {
      this.repeatPrintInfo.startSequenceNumber = row.sequenceNumberFrom;
      this.repeatPrintInfo.endSequenceNumber = row.sequenceNumberTo;
      this.repeatPrintInfo.generationId = row.id;
      try {
        const res = await getPrintHistory(row.id);
        const data = res.data.data;
        this.repeatPrintInfo.labelTemplateName = data.labelTemplateName;
        this.repeatPrintInfo.name = data.labelTemplateName;
        this.repeatPrintInfo.equipmentName = data.equipmentName;
        this.repeatPrintInfo.equipmentId = data.equipmentId;
        this.repeatPrintInfo.labelTemplateId = data.labelTemplateId;
      } catch (e) {
        console.log(e);
      }
      this.printInfoModel = true;
    },
    printSubmit() {
      this.$refs.printForm.validate(async (valid, done) => {
        if (valid) {
          try {
            const params = {
              ...this.repeatPrintInfo,
              fromSequenceNumber: this.repeatPrintInfo.startSequenceNumber,
              toSequenceNumber: this.repeatPrintInfo.endSequenceNumber
            };
            delete params.startSequenceNumber;
            delete params.endSequenceNumber;
            const res = await packPrint(params);
            this.printInfoModel = false;
            this.$message({
              type: 'success',
              message: '重打成功'
            });
          } catch (e) {
            console.warn(e);
          }
        }
        done();
      });
    },
    /**
     * 获取选择的模态框行数据
     */
    arePropertiesEqual(arr, prop1, prop2, prop3, prop4) {
      if (arr.length < 2) {
        return true; // 如果数组长度小于 2，则无需比较，直接返回 true
      }
      const firstObj = arr[0]; // 获取第一个对象
      for (let i = 1; i < arr.length; i++) {
        const currentObj = arr[i];
        if (currentObj[prop1] !== firstObj[prop1] || currentObj[prop2] !== firstObj[prop2] || currentObj[prop3] !== firstObj[prop3] || currentObj[prop4] !== firstObj[prop4]) {
          return false; // 如果有任何一个对象的属性值与第一个对象不相等，则返回 false
        }
      }
      return true; // 所有对象的属性值相等，返回 true
    },
    async getSelectedRows(rowData) {
      switch (this.modalName) {
        case 'otherReceiveMoal':
          try {
            this.$refs.otherInfo && this.$refs.otherInfo.resetFields();
            //动代码的时候注意 configValue  === 'true' 是核达 rowData is Array  else 是产品通用 rowData is Object
            if (this.configValue === 'true') {
              /*     let flag = this._some(rowData, (item) => {
                return item.labelGenerationStatus == 1;
              });
              if (flag) {
                this.$message.warning('已完成代表在(原材料包装条码打印)中不可打印，需在(原材料包装条码增补)页面打印');
                return;
              }*/
              if (rowData.length === 0) {
                this.$refs.reciveDialog.hideModal();
                return;
              }
              const isCanCheck = this.arePropertiesEqual(rowData, 'vendorCode', 'partNo', 'partBrand', 'vendorLotNo');
              if (!isCanCheck) {
                this.$message.warning('选中的收料记录中有不属于同一个供应商同一个物料同一个品牌同一个供应商批次的，请重新选择！');
              } else {
                const info = rowData[0];
                const sheetNoList = [];
                rowData.forEach((item) => {
                  if (item.sheetNo) {
                    sheetNoList.push(item.sheetNo);
                  }
                });
                this.rawMaterialOtherForm.receiveRecord = sheetNoList.join(',') || '其他收料';
                this.partId = this._get(info, 'partMasterId', '');
                this.rawMaterialOtherForm.receivingIds = rowData.map((item) => item.id).join(',');
                this.rawMaterialOtherForm.partId = this._get(info, 'partMasterId', '');
                this.rawMaterialOtherForm.partNo = this._get(info, 'partNo', '');
                this.rawMaterialOtherForm.partName = this._get(info, 'partName', '');
                this.rawMaterialOtherForm.partModel = this._get(info, 'partModel', '');
                this.rawMaterialOtherForm.sequenceDefinitionId = this._get(info, 'packingSeqDefinitionId', '');
                this.rawMaterialOtherForm.sequenceName = this._get(info, 'packSeqDefinitionName', '');
                let receiveQuantity = 0;
                let quantityPrinted = 0;
                rowData.forEach((item) => {
                  let value = Number(item.receiveQuantity);
                  receiveQuantity += value;
                  let quantityPrintedValue = Number(item.quantityPrinted);
                  quantityPrinted += quantityPrintedValue;
                });
                this.rawMaterialOtherForm.receiveQuantity = receiveQuantity;
                // minPackingQuantity 优先 receivingOption.mpq
                this.rawMaterialOtherForm.mpq = this._get(info, 'minPackingQuantity', '') || this._get(info, 'receivingOption.mpq', '');
                this.rawMaterialOtherForm.vendorDate = this._get(info, 'vendorDate', '');
                this.rawMaterialOtherForm.vendorLotNo = this._get(info, 'vendorLotNo', '');
                this.rawMaterialOtherForm.vendorCode = this._get(info, 'vendorCode', '');
                this.rawMaterialOtherForm.vendorName = this._get(info, 'vendorName', '');
                this.rawMaterialOtherForm.uom = this._get(info, 'uom', '');
                //this._get(info, 'quantityPrinted', '');
                this.rawMaterialOtherForm.quantityPrinted = quantityPrinted;
                this.rawMaterialOtherForm.remark = '';
                this.rawMaterialOtherForm.inspectionLotNo = this._get(info, 'inspectionLotNo', '');
                this.rawMaterialOtherForm.partLotNo = this._get(info, 'dateCode', '');
                this.rawMaterialOtherForm.materialBrand = this._get(info, 'partBrand', '');

                const labelTemplateId = this._get(info, 'labelTemplateId', '');
                const labelTemplateName = this._get(info, 'labelTemplateName', '');
                this.$refs.printInfo.setPrintLabel(labelTemplateId, labelTemplateName);
                this.printInfo.labelTemplateId = labelTemplateId;
                this.printInfo.dataId = this._get(info, 'dataId', '');
                if (this.printInfo.dataId) {
                  this.getDetail(this.printInfo.dataId);
                }
                this.$refs.reciveDialog.hideModal();
                this.rawMaterialOtherForm.generationQuantity = '';
                if (!info.labelTemplateId || !info.packingSeqDefinitionId) {
                  await this.setDefaultInfo(info.partNo);
                }
                if (this.rawMaterialOtherForm.sequenceDefinitionId) {
                  this.getSequencedefinitionDetail(this.rawMaterialOtherForm.sequenceDefinitionId);
                }
                this.getSequenceRecordById(this.rawMaterialOtherForm.receivingIds);
              }
            } else {
              if (Object.keys(rowData).length === 0) {
                return;
              }
              // if (rowData.labelGenerationStatus === 1) {
              //   this.$message.warning('已完成代表在(原材料包装条码打印)中不可打印，需在(原材料包装条码增补)页面打印');
              //   return;
              // }
              this.rawMaterialOtherForm.receiveRecord = rowData.sheetNo || '其他收料';
              this.partId = this._get(rowData, 'partMasterId', '');
              this.rawMaterialOtherForm.receivingIds = this._get(rowData, 'id', '');
              this.rawMaterialOtherForm.partId = this._get(rowData, 'partMasterId', '');
              this.rawMaterialOtherForm.partNo = this._get(rowData, 'partNo', '');
              this.rawMaterialOtherForm.partName = this._get(rowData, 'partName', '');
              this.rawMaterialOtherForm.partModel = this._get(rowData, 'partModel', '');
              this.rawMaterialOtherForm.sequenceDefinitionId = this._get(rowData, 'packingSeqDefinitionId', '');
              this.rawMaterialOtherForm.sequenceName = this._get(rowData, 'packSeqDefinitionName', '');
              this.rawMaterialOtherForm.receiveQuantity = rowData.receiveQuantity;
              this.rawMaterialOtherForm.uom = this._get(rowData, 'uom', '');
              // minPackingQuantity 优先 receivingOption.mpq
              this.rawMaterialOtherForm.mpq = this._get(rowData, 'minPackingQuantity', '') || this._get(rowData, 'receivingOption.mpq', '');
              this.rawMaterialOtherForm.vendorDate = this._get(rowData, 'vendorDate', '');
              this.rawMaterialOtherForm.vendorLotNo = this._get(rowData, 'vendorLotNo', '');
              this.rawMaterialOtherForm.vendorCode = this._get(rowData, 'vendorCode', '');
              this.rawMaterialOtherForm.vendorName = this._get(rowData, 'vendorName', '');
              this.rawMaterialOtherForm.quantityPrinted = this._get(rowData, 'quantityPrinted', '');
              this.rawMaterialOtherForm.remark = '';
              this.rawMaterialOtherForm.inspectionLotNo = this._get(rowData, 'inspectionLotNo', '');
              this.rawMaterialOtherForm.partLotNo = this._get(rowData, 'dateCode', '');
              this.rawMaterialOtherForm.materialBrand = this._get(rowData, 'partBrand', '');

              const labelTemplateId = this._get(rowData, 'labelTemplateId', '');
              const labelTemplateName = this._get(rowData, 'labelTemplateName', '');
              this.$refs.printInfo.setPrintLabel(labelTemplateId, labelTemplateName);
              this.printInfo.labelTemplateId = labelTemplateId;
              this.printInfo.dataId = this._get(rowData, 'dataId', '');
              if (this.printInfo.dataId) {
                this.getDetail(this.printInfo.dataId);
              }

              this.rawMaterialOtherForm.generationQuantity = '';
              if (!rowData.labelTemplateId || !rowData.packingSeqDefinitionId) {
                await this.setDefaultInfo(rowData.partNo);
              }
              if (this.rawMaterialOtherForm.sequenceDefinitionId) {
                this.getSequencedefinitionDetail(this.rawMaterialOtherForm.sequenceDefinitionId);
              }

              this.getSequenceRecordById(this.rawMaterialOtherForm.receivingIds);
            }
          } catch (e) {
            console.warn(e);
          }

          break;
        case 'serialnoModal':
          this.rawMaterialOtherForm.sequenceName = this._get(rowData, 'name', '');
          this.rawMaterialOtherForm.sequenceDefinitionId = this._get(rowData, 'id', '');
          this.sequenceRuleInfo.id = this._get(rowData, 'id', '');
          this.sequenceRuleInfo.name = this._get(rowData, 'name', '');
          this.sequenceRuleInfo.sequenceNo = this._get(rowData, 'sequenceNo', '');
          this.sequenceRuleInfo.sequenceNoFormat = this._get(rowData, 'sequenceNoFormat', '');
          this.sequenceRuleInfo.sequenceNoFormatZh = this._get(rowData, 'sequenceNoFormatZh', '');
          this.sequenceRuleInfo.seqNoFormatDemo = this._get(rowData, 'seqNoFormatDemo', '');
          this.sequenceRuleInfo.containsSequenceNo = this._get(rowData, 'containsSequenceNo', true);
          this.sequenceRuleInfo.charactersCount = this._get(rowData, 'charactersCount', 0);
          this.seqNoConvert();
          this.preview(this.rawMaterialOtherForm, 1);
          break;
        case 'printersModal':
          this.repeatPrintInfo.equipmentId = this._get(rowData, 'id', '');
          this.repeatPrintInfo.equipmentName = this._get(rowData, 'name', '');
          break;
        case 'labelTemplateModal':
          this.repeatPrintInfo.labelTemplateId = this._get(rowData, 'id', '');
          this.repeatPrintInfo.name = this._get(rowData, 'name', '');
          break;
        default:
          break;
      }
    },
    handleClick() {},
    /*
     * 根据序列号规则ID查询详情
     */
    getSequencedefinitionDetail(sequencedefinitionId) {
      getSequencedefinitionDetail(sequencedefinitionId).then((res) => {
        this.$set(this.sequenceRuleInfo, 'name', this._get(res, 'data.data.name', ''));
        this.$set(this.sequenceRuleInfo, 'sequenceNoFormat', this._get(res, 'data.data.sequenceNoFormat', ''));
        this.$set(this.sequenceRuleInfo, 'sequenceNoFormatZh', this._get(res, 'data.data.sequenceNoFormatZh', ''));
        this.$set(this.sequenceRuleInfo, 'seqNoFormatDemo', this._get(res, 'data.data.seqNoFormatDemo', ''));
        this.$set(this.sequenceRuleInfo, 'containsSequenceNo', this._get(res, 'data.data.containsSequenceNo', true));
        this.$set(this.sequenceRuleInfo, 'charactersCount', this._get(res, 'data.data.charactersCount', 0));
        this.seqNoConvert();
      });
    },
    serialnoRowClick(row) {
      this.selectionInfo = row;
      this.$refs.serialNoGenerationRecord.toggleSelection(row);
    },
    async setDefaultInfo(partNo) {
      try {
        const res = await getDefault({ partNo });
        const data = res.data.data || {};
        const { labelTemplateName = '', labelTemplateId = '', sequenceDefinitionName = '', sequenceDefinitionId = '', equipmentId = '', equipmentName = '' } = data;
        this.$refs.printInfo.setDefaultInfo(labelTemplateId, labelTemplateName, equipmentId, equipmentName);
        Object.assign(this.printInfo, { labelTemplateId, labelTemplateName, equipmentId, equipmentName });
        this.rawMaterialOtherForm.sequenceName = sequenceDefinitionName;
        this.rawMaterialOtherForm.sequenceDefinitionId = sequenceDefinitionId;
      } catch (e) {
        console.warn(e);
      }
    },
    rowStyle({ row, column, rowIndex }) {
      if (!Object.keys(this.selectionInfo).length) {
        return;
      }
      if (Object.keys(this.selectionInfo).length && row.id === this.selectionInfo.id) {
        return {
          backgroundColor: '#caf982'
        };
      }
    },
    /*
     * 序列号规则转换中文
     * @param sequenceNoValue 序列号规则
     * @param sequenceNo 序列号规则起始流水号
     */
    seqNoConvert() {
      let seqNoRules = [];
      this._forEach(getSeqNoRules(), (item) => {
        seqNoRules = [...seqNoRules, ...item.value];
      });
      let splitList = this.sequenceRuleInfo.sequenceNoFormat.split('');
      //在[前加空格  ]后加空格
      splitList = splitList.map((item) => {
        if (item === '[') {
          return ' [';
        } else if (item === ']') {
          return '] ';
        } else {
          return item;
        }
      });
      splitList = splitList.join('');
      //按空格拆分字符串
      splitList = splitList.split(' ');
      //匹配中文
      let splitArr = this._map(splitList, (item) => {
        this._forEach(seqNoRules, (ele) => {
          if (item === ele.key) {
            item = ele.value;
          }
        });
        return item;
      });
      //去除空格
      splitArr = splitArr.filter(function (s) {
        return s && s.trim();
      });
      //转换后给序列号规则赋值
      this.sequenceRuleInfo.sequenceNoFormatZh = splitArr.join('+');
    },
    /**
     * 获取打印机和打印模版信息
     */
    getPrintInfo(printInfo) {
      if (printInfo.printersId) {
        this.printInfo.printersId = printInfo.printersId;
      }
      if (printInfo.labelTemplateId) {
        this.printInfo.labelTemplateId = printInfo.labelTemplateId;
        const dataId = printInfo.dataId;
        if (dataId) {
          this.getDetail(printInfo.dataId);
        } else {
          this.fieldList = [];
        }
      }
    },
    async getDetail(id) {
      try {
        this.btnLoading = true;
        const res = await getDetail(id);
        const data = res.data.data;
        if (data.fieldList) {
          this.fieldList = data.fieldList;
          const column = [];
          data.fieldList.forEach((item) => {
            const obj = {};
            obj.type = item.controlType;
            obj.label = item.name;
            obj.value = item.defaultValue;
            obj.prop = item.field;
            if (item.isRequired) {
              obj.rules = [
                {
                  required: true,
                  message: `请选择${item.name}`
                }
              ];
            }
            if (item.controlType === 'date') {
              obj.format = 'yyyy-MM-dd';
              obj.valueFormat = 'yyyy-MM-dd';
              obj.value = this.$moment(obj.defaultValue).format('YYYY-MM-DD');
            } else if (item.controlType === 'datetime') {
              obj.format = 'yyyy-MM-dd HH:mm:ss';
              obj.valueFormat = 'yyyy-MM-dd HH:mm:ss';
              obj.value = this.$moment(obj.defaultValue).format('yyyy-MM-DD HH:mm:ss');
            } else if (item.controlType === 'select') {
              let data = [];
              if (item.dicData) {
                data = item.dicData.split(',').map((i) => ({ label: i, value: i }));
              }
              obj.dicData = data;
              obj.value = item.defaultValue;
            }
            column.push(obj);
          });
          this.$set(this.otherInfoOption, 'column', column);
        }
      } catch (e) {
        console.warn(e);
      } finally {
        this.btnLoading = false;
      }
    },
    openCommonModal(type) {
      // sheetNoModal / otherReceiveMoal
      this.modalName = type;

      this.$refs.reciveDialog.showModal();
      let url;
      if (type === 'otherReceiveMoal') {
        url = `/api/mes-warehouse/receiving/page`;
      }
      this.tableOption = {
        modalTitle: `请选择收料记录（双击进行选择）`,
        url,
        isPage: true,
        rowSelectionType: this.configValue === 'true' ? '' : 'single',
        openSubmitCheck: this.configValue === 'true',
        searchLabelWidth: 120,
        searchSpan: 8,
        height: 280,
        columnBtn: true,
        refreshBtn: true,
        columnDefs: [
          {
            label: '单据号',
            prop: 'sheetNo',
            search: true
          },
          {
            label: '供应商编码',
            prop: 'vendorCode',
            search: true
          },
          {
            label: '供应商名称',
            prop: 'vendorName',
            search: true
          },
          {
            label: '物料编码',
            prop: 'partNo',
            search: true
          },
          {
            label: '物料名称',
            prop: 'partName',
            search: true
          },
          {
            label: '物料规格',
            prop: 'partModel'
          },
          {
            label: '收料数量',
            prop: 'receiveQuantity'
          },
          // {
          //   label: '实收数量',
          //   prop: 'actuallyReceive'
          // },
          // {
          //   label: '已生成数量',
          //   prop: 'quantityPrinted'
          // },
          /* {
            label: '标签生成状态',
            prop: 'labelGenerationStatus',
            type: 'select',
            dicData: [
              {
                label: '已完成',
                value: 1
              },
              {
                label: '未完成',
                value: 0
              }
            ],
            search: true
          },*/
          {
            label: '单位',
            prop: 'uom'
          },

          {
            label: '生产日期',
            prop: 'vendorDate'
          },
          {
            label: 'D/C',
            prop: 'dateCode'
          },
          {
            label: '品牌',
            prop: 'partBrand',
            search: true
          },
          {
            label: '供应商批次',
            prop: 'vendorLotNo'
          },
          {
            label: '收料人',
            prop: 'receivingByName'
          },
          {
            label: '收料时间',
            prop: 'createTime',
            search: true,
            hide: true,
            searchSpan: 12,
            type: 'date',
            searchType: 'datetimerange',
            format: 'yyyy-MM-dd HH:mm:ss',
            valueFormat: 'yyyy-MM-dd HH:mm:ss',
            startPlaceholder: '开始日期',
            endPlaceholder: '结束日期'
          },
          {
            label: '收料时间',
            prop: 'receiveTime'
          },
          {
            label: '送检单号',
            prop: 'examineNo'
          }
        ]
      };
    },

    /**
     * 打开序列号规则选择模态框
     */
    openSerialnoCommonModal() {
      this.modalName = 'serialnoModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择序列号规则（双击进行选择）',
        url: '/api/mes-admin/sequencedefinition/page?type=material&subTypeStr=RAW_MATERIAL_PACKAGING,ACCESSORIES',
        isPage: true,
        rowSelectionType: 'single',
        // searchMenuPosition: 'left',
        searchMenuSpan: 24,
        columnDefs: [
          {
            label: '大类',
            prop: 'type',
            type: 'select',
            dicData: [{ label: '物料', value: 'MATERIAL' }]
          },
          {
            label: '小类',
            prop: 'subType',
            searchSpan: 8,
            dicData: [
              { label: '原材料包装', value: 'RAW_MATERIAL_PACKAGING' },
              { label: '辅料', value: 'ACCESSORIES' }
            ],
            type: 'select',
            search: true
          },
          {
            label: '序列号规则名称',
            prop: 'name',
            search: true,
            searchLabelWidth: 150,
            searchSpan: 8
          },
          {
            label: '序列号规则编码',
            prop: 'code',
            search: true,
            searchLabelWidth: 150,
            searchSpan: 8
          },
          {
            label: '起始流水号',
            prop: 'startSequenceNo'
          },
          {
            label: '结束流水号',
            prop: 'endSequenceNo'
          },
          {
            label: '序列号规则',
            prop: 'sequenceNoFormat'
          }
        ]
      };
    },

    /**
     * 获取打印机
     */
    openPrintersModal() {
      this.modalName = 'printersModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择打印机（双击进行选择）',
        url: '/api/mes-product/ems-equipment/page?type=PRINTER',
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '打印机编码',
            prop: 'code',
            search: true,
            searchLabelWidth: 110
          },
          {
            label: '打印机名称',
            prop: 'name',
            search: true,
            searchLabelWidth: 110
          }
        ]
      };
    },
    /**
     * 打开标签模板模态框
     */
    openLabelTemplateModal() {
      this.modalName = 'labelTemplateModal';
      this.$refs.commonModalTemplate.showModal();
      this.tableOption = {
        modalTitle: '选择标签模版（双击进行选择）',
        url: `/api/mes-admin/labeltemplate/page?status=1&type=MATERIAL&subTypeStr=RAW_MATERIAL_PACKAGING,ACCESSORIES`,
        isPage: true,
        rowSelectionType: 'single',
        columnDefs: [
          {
            label: '大类',
            prop: 'type',
            type: 'select',
            dicUrl: '/api/blade-system/dict/dictionary?code=dalei',
            cascader: ['subType'],
            props: {
              label: 'dictValue',
              value: 'dictKey'
            },
            // change: ({ column, value }) => {
            //   this.getSubTypeData(value);
            // },
            search: true
          },
          {
            label: '小类',
            prop: 'subType',
            // dicUrl: '/api/blade-system/dict/dictionary?code={{key}}',
            // props: {
            //   label: 'dictValue',
            //   value: 'dictKey'
            // },
            formatter: (row) => {
              const subTypeMap = {
                WORKORDER: '工单',
                FLOW_CARD: '流程卡',
                WAREHOUSE: '仓库',
                WORKSTATION: '产线（工位）',
                STORAGE_AREA: '存储区域',
                EQUIPEMENT: '设备及其属性',
                TOOL: '工装/夹具',
                VEHICLE: '载具',
                INSPECTION_RESULTS: '检验结果',
                FAULT_PHENOMENON: '故障现象/故障类别',
                RAW_MATERIAL_PACKAGING: '原材料包装',
                WORK_IN_PROGRESS: '在制品',
                FINISHED_PRODUCT_PACKAGING: '成品包装',
                ACCESSORIES: '辅料',
                PALLET: '栈板',
                SCM_DO: 'SCM送货单'
              };
              return subTypeMap[row.subType] || '';
            },
            fromslot: true,
            type: 'select',
            search: true
          },
          {
            label: '模板名称',
            prop: 'name',
            search: true
          },
          {
            label: '模版代码',
            prop: 'code',
            search: true
          },
          {
            label: '版本名称',
            prop: 'version'
          },
          {
            label: '缩略图',
            prop: 'thumbnailUrl'
          },
          {
            label: '标签地址',
            prop: 'fileUrl'
          },
          {
            label: '打印列数',
            prop: 'columnCount'
          },
          {
            label: '打印份数',
            prop: 'copies'
          },
          {
            label: '备注',
            prop: 'remark'
          }
        ]
      };
    },
    newKey() {
      this.timer = new Date().getTime();
    },
    handleCreatLabel() {
      if (!this.rawMaterialOtherForm.partNo) {
        this.$message({
          type: 'warning',
          message: '请选择物料!'
        });
        return;
      }
      if (!this.rawMaterialOtherForm.sequenceName) {
        this.$message({
          type: 'warning',
          message: '请选择序列号规则!'
        });
        return;
      }
      if (!this.rawMaterialOtherForm.mpq) {
        this.$message({
          type: 'warning',
          message: '请输入MPQ!'
        });
        return;
      }
      if (!this.rawMaterialOtherForm.generationQuantity) {
        this.$message({
          type: 'warning',
          message: '请输入本次生成数量!'
        });
        return;
      }
      let reg1 = /^\d+(?:\.\d{0,3})?$/;
      if (!reg1.test(this.rawMaterialOtherForm.mpq)) {
        this.$message({
          type: 'warning',
          message: '小数点最多为3位'
        });
        return;
      }
      if (!this.rawMaterialOtherForm.vendorDate) {
        this.$message({
          type: 'warning',
          message: '请选择生产日期!'
        });
        return;
      }
      if (Number(this.rawMaterialOtherForm.receiveQuantity) < Number(this.rawMaterialOtherForm.generationQuantity)) {
        this.$message({
          type: 'warning',
          message: '本次生成数量不能大于接收数量!'
        });
        return;
      }
      // 向上取整
      const number = Math.ceil(this.rawMaterialOtherForm.generationQuantity / this.rawMaterialOtherForm.mpq);
      this.confirmModel = {
        vendorName: this.rawMaterialOtherForm.vendorName,
        partNo: this.rawMaterialOtherForm.partNo,
        partName: this.rawMaterialOtherForm.partName,
        partModel: this.rawMaterialOtherForm.partModel,
        mpq: this.rawMaterialOtherForm.mpq,
        generationQuantity: this.rawMaterialOtherForm.generationQuantity,
        number
      };
      this.confirmVisible = true;
    },
    /**
     * 序列号规则时间修改
     */
    openTimeConfigModel() {
      this.timeConfigModel = true;
      this.timeConfig.year = this.timeConfig.year ? this.timeConfig.year : this.$moment().format('YYYY');
      this.timeConfig.month = this.timeConfig.month ? this.timeConfig.month : this.$moment().format('MM');
      this.timeConfig.week = this.timeConfig.week ? this.timeConfig.week : getYearWeek();
      this.timeConfig.day = this.timeConfig.day ? this.timeConfig.day : this.$moment().format('DD');
      this.$nextTick(() => {
        let column = this.$refs.timeConfigForm.option.column;
        if (
          (this.sequenceRuleInfo.sequenceNoFormat && this.sequenceRuleInfo.sequenceNoFormat.indexOf('[YYYY]') > -1) ||
          this.sequenceRuleInfo.sequenceNoFormat.indexOf('[YY]') > -1
        ) {
          let year = this.findObject(column, 'year');
          year.display = true;
        }
        if (this.sequenceRuleInfo.sequenceNoFormat && this.sequenceRuleInfo.sequenceNoFormat.indexOf('[M]') > -1) {
          let month = this.findObject(column, 'month');
          month.display = true;
        }
        if (this.sequenceRuleInfo.sequenceNoFormat && this.sequenceRuleInfo.sequenceNoFormat.indexOf('[W]') > -1) {
          let week = this.findObject(column, 'week');
          week.display = true;
        }
        if (this.sequenceRuleInfo.sequenceNoFormat && this.sequenceRuleInfo.sequenceNoFormat.indexOf('[D]') > -1) {
          let day = this.findObject(column, 'day');
          day.display = true;
        }
      });
    },
    onSaveTimeConfig() {
      //验证是否传递序列号规则中年份日期
      if (
        (this.sequenceRuleInfo.sequenceNoFormat && this.sequenceRuleInfo.sequenceNoFormat.indexOf('[YYYY]') > -1) ||
        this.sequenceRuleInfo.sequenceNoFormat.indexOf('[YY]') > -1
      ) {
        if (!this.timeConfig.year) {
          this.$message({
            type: 'error',
            message: '请选择序列号规则中的年份！'
          });
          return;
        }
      }
      if (this.sequenceRuleInfo.sequenceNoFormat && this.sequenceRuleInfo.sequenceNoFormat.indexOf('[M]') > -1) {
        if (!this.timeConfig.month) {
          this.$message({
            type: 'error',
            message: '请选择序列号规则中的月份！'
          });
          return;
        }
      }
      if (this.sequenceRuleInfo.sequenceNoFormat && this.sequenceRuleInfo.sequenceNoFormat.indexOf('[W]') > -1) {
        if (!this.timeConfig.week) {
          this.$message({
            type: 'error',
            message: '请输入序列号规则中的周数！'
          });
          return;
        }
      }
      if (this.sequenceRuleInfo.sequenceNoFormat && this.sequenceRuleInfo.sequenceNoFormat.indexOf('[D]') > -1) {
        if (!this.timeConfig.day) {
          this.$message({
            type: 'error',
            message: '请选择序列号规则中的日期！'
          });
          return;
        }
      }
      this.timeConfigModel = false;
    },
    /**
     * 根据id获取所有生成记录
     */
    getSequenceRecordById(id) {
      let params = {
        sourceId: id,
        size: this.page.pageSize,
        current: this.page.currentPage
      };
      this.sourceId = id;
      this.loading = true;
      getSourceList(params)
        .then(
          (res) => {
            this.serialnoData = this._get(res, 'data.data.records', []);
            this.page.total = this._get(res, 'data.data.total', 0);
            if (this.serialnoData.length && this.serialnoData[0].isPrinted === 0) {
              this.serialnoRowClick(this.serialnoData[0]);
            }
          },
          (error) => {
            this.serialnoData = [];
            this.page.total = 0;
          }
        )
        .finally((this.loading = false));
    },
    preview(row, quantity) {
      console.log(row, 'row');
      if (row.sequenceDefinitionId == '' || row.sequenceDefinitionId == null) {
        return;
      }
      let attr = {
        mpq: row.mpq,
        receivingIds: row.receivingIds,
        generationQuantity: quantity,
        sequenceDefinitionId: row.sequenceDefinitionId,
        dateCode: row.partLotNo,
        vendorLotNo: row.vendorLotNo,
        vendorDate: row.vendorDate,
        materialBrand: row.materialBrand,
        timeConfig: this.timeConfig
      };
      receivingPreview(attr).then(
        (res) => {
          this.$set(this.sequenceRuleInfo, 'sequenceNo', this._get(res, 'data.data.startSequenceNo', ''));
          this.$set(this.sequenceRuleInfo, 'quantity', this._get(res, 'data.data.quantity', ''));
          this.$set(this.sequenceRuleInfo, 'sequenceNumberFrom', this._get(res, 'data.data.sequenceNumberFrom', ''));
          this.$set(this.sequenceRuleInfo, 'snLength', this._get(res, 'data.data.snLength', ''));
          this.$set(this.sequenceRuleInfo, 'sequenceNumberTo', this._get(res, 'data.data.sequenceNumberTo', ''));
        },
        (error) => {}
      );
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
      this.getSequenceRecordById(this.sourceId);
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
      this.getSequenceRecordById(this.sourceId);
    }
  }
};
</script>

<style scoped lang="scss">
.sequenceInfo {
  table {
    width: 100%;
    height: auto;
    margin-bottom: 10px;
    font-size: 14px;

    th {
      border: 1px solid #ebeef5;
      background: #fafafa;
      height: 30px;
    }

    tr {
      border: 1px solid #ebeef5;
    }

    td {
      border: 1px solid #ebeef5;
      height: auto;
      text-align: center;
    }

    p {
      margin-left: 30px;
    }
  }
}

.newFormStyle {
  ::v-deep .el-form-item--small.el-form-item {
    margin-bottom: 5px;
  }

  ::v-deep .el-input--small input {
    height: 30px;
    line-height: 30px;
  }
}

.generateSerialNoInfo {
  div {
    margin: 5px 10px;
  }
}

.printButton {
  text-align: right;
}

.btn-group {
  display: flex;
  justify-content: center;
}

.mt8 {
  margin-top: 8px;
}

::v-deep .el-table__body tr.current-row > td {
  background-color: transparent;
}

//::v-deep .avue-crud__menu {
//  display: none;
//}

.form-contant {
}

.input-text {
  ::v-deep .el-input__inner {
    color: red;
    font-weight: bold;
  }
}
</style>
